package cn.pn.project.controller;

import cn.pn.project.client.schedule.RestSeatClient;
import cn.pn.project.common.DtoUtil;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;

@RestController
@RequestMapping("/api")
public class SeatController {

    @Autowired
    private RestSeatClient restSeatClient;

    @RequestMapping(value = "/p/findSeat",method = RequestMethod.POST)
    public Object getSeatByPlaceId(Integer placeId) throws SQLException {
        if(placeId==null){
            return DtoUtil.returnSuccess("参数为空","5006");
        }
        System.out.println(JSON.toJSONString(restSeatClient.getSeatByPlaceId(placeId),true));
        return DtoUtil.returnSuccess("获取成功",restSeatClient.getSeatByPlaceId(placeId));
        //return "successCallback("+JSON.toJSONString(restSeatClient.getSeatByPlaceId(placeId),true)+")";
    }

}
